<template>
  <div>
    <!-- 1.0 表单查询 -->
    <el-form :inline="true" :model="searchForm" class="demo-form-inline">
      <el-form-item label="活动区域">
        <el-date-picker
          v-model="searchForm.date"
          type="daterange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">查询</el-button>
      </el-form-item>
    </el-form>

    <!-- 2.0 图表显示 -->
    <div class="charts">
      <div ref="main" style="width: 800px;height:400px;"></div>
    </div>
  </div>
</template>

<script>
import * as echarts from 'echarts'
import option from './data/options'

export default {
  data() {
    return {
      searchForm: {
        date: []
      }
    }
  },
  mounted() {
    this.initCharts()
  },
  methods: {
    onSubmit() {
      console.log('submit!')
    },
    initCharts() {
      // 基于准备好的dom，初始化echarts实例
      var myChart = echarts.init(this.$refs.main)

      // 指定图表的配置项和数据

      // 使用刚指定的配置项和数据显示图表。
      myChart.setOption(option)
    }
  }
}
</script>

<style lang="less" scoped>
.charts {
  margin-top: 40px;
  background-color: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px 0;
}
</style>
